<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box1{
            width: 200px;
            height: 200px;
            background-color: red;
        }
    </style>
    <script>
        window.onload = function(){
            var box1 = document.getElementById("box1");
            //滚轮事件onwheel
            box1.onwheel = function(event){
                //deltaX返回鼠标滚轮的水平滚动量  deltaY垂直滚动量
                // alert(event.deltaY)
                if(event.deltaY > 0 && box1.clientHeight > 20){
                    box1.style.height = box1.clientHeight - 10 + "px"; 
                }else if(event.deltaY < 0 && box1.clientHeight < 500){
                    box1.style.height = box1.clientHeight + 10 +"px";
                }
            };
        };
    </script>
</head>
<body>
    <div id="box1"></div>
    
</body>
</html>